package com.nian.message.rocketmq.consumer;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 用途：
 * 开发：zhangmj
 * 日期：2020/4/10 0010 15:45
 */
@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = "nian-message-service-consumer-group-t", topic = "producer_topic_shiwu_test_")
public class ConsumerTransactionListenerSimple implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt msg) {
        log.info("事务 *************************消费：事务主题************************");
        log.info("事务 ******************producer_topic_shiwu_test_******************");
        log.info("事务 CONTEXT：{}" , msg.toString());
        log.info("事务 CONTEXT：{}" , JSONObject.toJSONString(msg));
//        throw new RuntimeException("事务::::测试事务异常");
    }
}
